package net.ocps.tchs.scarymazegame.splash;

import net.ocps.tchs.scarymazegame.scarymazegame;
import  net.ocps.tchs.scarymazegame.tween.SpriteAccessor;
import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.TweenManager;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class splash extends Game implements Screen {
	
	private SpriteBatch batch;
	private Sprite splash;
	private TweenManager tweenManager;
	public static boolean done = false;
	@Override
    public void render(float delta) {
		Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		
		tweenManager.update(delta);
		
		batch.begin();
		splash.draw(batch);
		batch.end();
    }
	@Override
    public void resize(int width, int height) {
		
    }
	@Override
	public void show() {
		batch = new SpriteBatch();
		tweenManager = new TweenManager();
		Tween.registerAccessor(Sprite.class, new SpriteAccessor());
		
		Texture splashTexture= new Texture("data/splashedit.png");
		splash = new Sprite(splashTexture);
		splash.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	/*	
		Tween.set(splash, SpriteAccessor.ALPHA).target(0).start(tweenManager);
	Tween.to(splash, SpriteAccessor.ALPHA, 2).target(1).start(tweenManager);
		Tween.to(splash, SpriteAccessor.ALPHA, 3).target(0).delay(3).start(tweenManager);
*/
	/*	
	Tween.to(splash, SpriteAccessor.ALPHA, 1.5f).target(1).repeatYoyo(1,.5f).setCallback(new TweenCallBack() {
			public void onEvent(int type, BaseTween<?> source) {
				setScreen(scarymazegame());
			}
			
		}).start(tweenManager);
		
		*/
	     Tween.set(splash, SpriteAccessor.ALPHA).target(0).start(tweenManager);

	        Tween.to(splash, SpriteAccessor.ALPHA, .5f).target(1).repeatYoyo(1, .5f).setCallback(new TweenCallback() {

	            @Override
	            public void onEvent(int type, BaseTween<?> source) {
	        		System.out.println("Dooone");
	        		done = true;
	              //  setScreen(new scarymazegame());
	            }
	    }).start(tweenManager);

	//	setScreen(scarymazegame());
		
		
	}
    @Override
    public void hide() {
    	
    }
    @Override
    public void pause() {
    	
    }
    @Override
    public void resume() {
    	
    }
    @Override
    public void dispose() {	
    	
    }
	@Override
	public void create() {
		// TODO Auto-generated method stub
		
	}
}
